package com.example.demospring.common.entity;

import lombok.Data;
@Data
public abstract class Message {
    public static Message succeed(Object data){
        return new Message(MessageStatus.MS200,data){};
    }

    public static Message fail(String...reason){
        return new Message(MessageStatus.MS201,reason[0]){};
    }

    public static Message repeat(String data){
        return new Message(MessageStatus.MS202,data){};
    }

    public static Message error(Throwable data){
        return new Message(MessageStatus.MS500,data.getMessage()){};
    }

    //"status: 消息状态")
    private MessageStatus status;
    //"data : 消息内容(基于Object多态，可以兼容一切类型)
    private Object data;

    private Message(MessageStatus status, Object data) {
        this.status = status;
        this.data = data;
    }

}
